package com.ecfront.dao.impl;

import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.ecfront.dao.UserGradeDAO;
import com.ecfront.pojo.UserGrade;


/**
 * @version 1.0
 * @author www.ecfrom.com
 */

public class UserGradeDAOImpl extends HibernateDaoSupport implements UserGradeDAO {

	protected void initDao() {}

	public void save(UserGrade transientInstance) {
		getHibernateTemplate().saveOrUpdate(transientInstance);
	}

	public void delete(UserGrade persistentInstance) {
		getHibernateTemplate().delete(persistentInstance);
	}

	public UserGrade findById(java.lang.Integer id) {
		return (UserGrade) getHibernateTemplate().get(
					"com.ecfront.pojo.UserGrade", id);
	}

	public List findByExample(UserGrade instance) {
		return getHibernateTemplate().findByExample(instance);
	}

	public List findByProperty(String propertyName, Object value) {
		String queryString = "from UserGrade as model where model."
					+ propertyName + "= ?";
		return getHibernateTemplate().find(queryString, value);

	}

	public List findByUgName(Object ugName) {
		return findByProperty(UG_NAME, ugName);
	}

	public List findByUgImgUrl(Object ugImgUrl) {
		return findByProperty(UG_IMG_URL, ugImgUrl);
	}

	public List findByUgScore(Object ugScore) {
		return findByProperty(UG_SCORE, ugScore);
	}

	public List findAll() {
		String queryString = "from UserGrade";
		return getHibernateTemplate().find(queryString);
	}

	public static UserGradeDAO getFromApplicationContext(ApplicationContext ctx) {
		return (UserGradeDAO) ctx.getBean("UserGradeDAO");
	}
}